<%@ page contentType="text/html; charset=UTF-8"%>
<%@ taglib prefix="s" uri="/struts-tags" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
    <head>
        <title>Master一覧</title>
		<script language="JavaScript">
		function submitFormWithDbCode(dbcode) {
			masterForm.dbCode.value=dbcode;
			return true;
		}
		function submitFormWithAddMode(addMode) {
			masterForm.addMode.value=addMode;
			return true;
		}
		
		</script>
    </head>

<body>
	<s:form name="masterForm" method="POST" theme="simple">
		<s:hidden name="dbCode"/>
		<s:hidden name="addMode"/>
			<s:if test="%{masterManageValueList.size()!=0}">
				<%-- Master一覧レイアウト --%>
				<table class="pol_list" width="100%">
					<tr>
						<th width="20%">DBCode</th>
						<th width="20%">MASTER_GROUP</th>
						<th width="20%">MASTER_VALUE</th>
						<th width="30%">操作</th>
					</tr>
				<s:iterator value="masterManageValueList" status="rowstatus" id="list">
					<s:hidden name="masterManageValueList[%{#rowstatus.index}].dbCode" value="%{#list.dbCode}"/>
					<s:if test="#list.editFlag==1">
					<%-- Master覧編集モード --%>
						<tr>
							<td class="edit"><s:property value="dbCode" /></td>
							<td class="edit"><s:textfield size="20" maxlength="20" name="masterManageValueList[%{#rowstatus.index}].keyWord" /></td>
							<td class="edit"><s:textfield size="20" maxlength="20" name="masterManageValueList[%{#rowstatus.index}].disValue"/></td>
							<td class="edit">
								<s:submit btnId="X001" cssClass="btn_2" name="buttonId" value="更新" action="doMasterUpdate" onclick="javascript:submitFormWithDbCode(%{#list.dbCode});"/>
								<s:submit btnId="X002" cssClass="btn_2" name="buttonId" value="取消" action="masterManageList" />
							</td>
						</tr>			
					</s:if>				
					<s:else>
					<%-- Master一覧表示モード --%>
						<tr>
							<td><s:property value="dbCode" /></td>
							<td><s:property value="keyWord" /></td>
							<td><s:property value="disValue" /></td>
							<td>
								<s:submit btnId="X003" cssClass="btn_1" name="buttonId" value="編集" action="doMasterEdit" onclick="javascript:submitFormWithDbCode(%{#list.dbCode});"/>
								<s:submit btnId="X004" cssClass="btn_1" name="buttonId" value="削除" action="doMasterDelete" onclick="javascript:submitFormWithDbCode(%{#list.dbCode});"/>
								<s:if test="masterManageValueList.size() == (#rowstatus.index+1)">
								<s:if test="addMode==0">
									<s:submit btnId="X005" cssClass="btn_1" name="buttonId" value="追加" action="masterManageList" onclick="javascript:submitFormWithAddMode(1);"/>
								</s:if>
								</s:if>
							</td>
						</tr>
					</s:else>
				</s:iterator>

					<s:if test="addMode==1">
						<%-- Master一覧新規モード --%>
						<tr>
							<td class="edit"><!--<s:property value="%{masterManageValueList.size()+1}" />-->&nbsp;</td>
							<td class="edit"><s:textfield size="20" maxlength="20" name="addMasterManageValue.keyWord" /></td>
							<td class="edit"><s:textfield size="20" maxlength="20" name="addMasterManageValue.disValue"/></td>
							<td class="edit">
								<s:submit btnId="X006"  cssClass="btn_2" name="buttonId" value="登録" action="doMasterAdd"/>
								<s:submit btnId="X007" cssClass="btn_2" name="buttonId" value="取消" action="masterManageList" onclick="javascript:submitFormWithAddMode(0);"/>
							</td>				
						</tr>
					</s:if>

				</table>
			</s:if>
			<s:else>
			</s:else>
		
		<table class="pol_list"></table>
	</s:form>
</body>
</html>
